<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/24 0024
 * Time: 18:43
 */
use yii\helpers\Url;
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
<!--    <link href="./dist/css/bootstrap.min.css" rel="stylesheet">-->

    <!-- Custom styles for this template -->
    <link href="./css/signin.css" rel="stylesheet">


    <script src="./js/ie-emulation-modes-warning.js"></script>
    <script src="./js/jquery-1.5.2.min.js"></script>
    <script type="text/javascript">
     $(document).ready(function () {
//         if(Check()){
             $("#loginButton").click(function() {
                 var checkbox=document.getElementById('remember');
                 var zhi="";
                 if(checkbox.checked){
                     zhi="1";
                 }else{
                     zhi="0"
                 }
                 var action = $("#myForm").attr('action');
                 $.ajax({
                     type: "POST",
                     url: action,
                     dataType:"json",
                     data: {username: $("#username").val(),password: $("#password").val(),remember :zhi},
                     'success': function(json)
                     {
                         if(json.status) {
                             window.location.href = "?r=site";
                         }else {
                             $("#message").html("<p class='error'>"+json.msg+"</p>");
                         }
                     }
                 });
                 return false;
             });
//         }

     });

    </script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>

    <![endif]-->

</head>

<body>

<div class="container">

    <form class="form-signin" role="form" name="myForm" method="post" action="<?php echo Url::to(['site/login-submit'])?>" id="myForm">
        <h2 class="form-signin-heading">Please sign in</h2>
        <input type="text" class="form-control"   name="username" id="username" required autofocus>
        <input type="password" class="form-control"  name="password" id="password" required>
        <div class="checkbox">
            <label>
                <input type="checkbox" value="remember" id="remember" name="remember"> Automatic login within a week
            </label>
        </div>
        <div id="message"></div>
        <button class="btn btn-lg btn-primary btn-block" type="submit" name="login" id="loginButton">Sign in</button>
    </form>
    <div id="message"></div>

</div> <!-- /container -->


<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="./js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>

